
package com.kweative.lingua.demo.model;

import com.kweative.type.ICanDoNode;
import com.kweative.type.Node;
import com.kweative.type.Node.Type;
import java.io.Serializable;
import java.util.Date;

/**
 *
 * @author henrik
 */
public class ChatMessage implements ICanDoNode,Serializable {
    private UserModel user;
    private String message;
    private Date created;

    public ChatMessage(UserModel user, String message, Date created) {
        this.user = user;
        this.message = message;
        this.created = created;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public UserModel getUser() {
        return user;
    }

    public void setUser(UserModel user) {
        this.user = user;
    }

    public Node toNode() {
        Node node = new Node(this.getClass().getSimpleName(),Type.COMPLEX);
        node.setAttribute("created",created.toString());
        node.setAttribute("user",user.getUsername());
        node.setValue(message);
        return node;
    }

}
